﻿#include "AbstractBlock.h"
namespace CVV
{
namespace FlowChart
{

float AbstractBlock::m_aScale = 60;//越大，block越大
float AbstractBlock::m_bScale = 2; //越大。block越宽
float AbstractBlock::m_lineScale = 20;
AbstractBlock::AbstractBlock()
{
}

AbstractBlock::~AbstractBlock()
{

}

QString AbstractBlock::getBlockDom()
{
    return "<algorithm><branch></branch></algorithm>";
}

void AbstractBlock::drawBottomArrow(QPainter *canvas, const QPointF &aPoint, const QSizeF &aSize)
{
    QVector<QPointF> arrow;
    arrow << QPointF(aPoint.x() - aSize.width()/2.0, aPoint.y()-aSize.height()) <<
        aPoint << aPoint << QPointF(aPoint.x() + aSize.width()/2.0, aPoint.y()-aSize.height());
    canvas->drawLines(arrow);
}

void AbstractBlock::drawRightArrow(QPainter *canvas, const QPointF &aPoint, const QSizeF &aSize)
{
    QVector<QPointF> arrow;
    arrow << QPointF(aPoint.x() - aSize.width(), aPoint.y()-aSize.height()/2);
    arrow << aPoint;
    arrow << aPoint;
    arrow << QPointF(aPoint.x() - aSize.width(), aPoint.y()+aSize.height()/2);
    canvas->drawLines(arrow);
}

QString AbstractBlock::name() const
{
    return m_name;
}

void AbstractBlock::setName(const QString &name)
{
    m_name = name;
}

QRect AbstractBlock::postion() const
{
    return m_postion;
}

void AbstractBlock::setPostion(const QRect &postion)
{
    m_postion = postion;
}

QMargins AbstractBlock::margin() const
{
    return m_margin;
}

void AbstractBlock::setMargin(const QMargins &margin)
{
    m_margin = margin;
}

double AbstractBlock::zoom() const
{
    return m_zoom;
}

void AbstractBlock::setZoom(double zoom)
{
    m_zoom = zoom;
}

int AbstractBlock::penWidth() const
{
    return m_penWidth;
}

void AbstractBlock::setPenWidth(int penWidth)
{
    m_penWidth = penWidth;
}

QList<QBlock *> AbstractBlock::getBranchItem() const
{
    return m_branchItem;
}

void AbstractBlock::setBranchItem(const QList<QBlock *> &branchItem)
{
    m_branchItem = branchItem;
}

QString AbstractBlock::runState() const
{
    return m_runState;
}

void AbstractBlock::setState(const QString& state)
{
    m_runState = state;
}

int AbstractBlock::getReferenceStatus()
{
    return m_iReferenceStatus;
}

void AbstractBlock::setReferenceStatus(int rState)
{
    m_iReferenceStatus = rState;
}

}
}
